﻿namespace NHibernateExample
{
    public class CamelotSharePointConnectionProvider : NHibernate.Connection.IConnectionProvider
    {
        private string _connectionString;

        public void CloseConnection(System.Data.IDbConnection conn)
        {
            conn.Close();
        }

        public void Configure(System.Collections.Generic.IDictionary<string, string> settings)
        {
            _connectionString = settings["connection.connection_string"];
        }

        public NHibernate.Driver.IDriver Driver { get { return new CamelotSharePointDriver(); } }

        public System.Data.IDbConnection GetConnection()
        {
            var conn = new Camelot.SharePointConnector.Data.SharePointConnection(_connectionString);
            conn.Open();
            return conn;
        }

        public void Dispose()
        {
            return;
        }
    }
}
